/*
 * read_xml_cnf.c
 *
 *  Created on: 2010-9-28
 *      Author: lius
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mxml.h>

int my_create_xml()
{
    mxml_node_t *xml;    /* <?xml ... ?> */
    mxml_node_t *data;   /* <data> */
    mxml_node_t *node;   /* <node> */
    mxml_node_t *group;  /* <group> */

    xml = mxmlNewXML("1.0");

    data = mxmlNewElement(xml, "data");

        node = mxmlNewElement(data, "node");
        mxmlNewText(node, 0, "val1");
        node = mxmlNewElement(data, "node");
        mxmlNewText(node, 0, "val2");
        node = mxmlNewElement(data, "node");
        mxmlNewText(node, 0, "val3");

        group = mxmlNewElement(data, "group");

            node = mxmlNewElement(group, "node");
            mxmlNewText(node, 0, "val4");
            node = mxmlNewElement(group, "node");
            mxmlNewText(node, 0, "val5");
            node = mxmlNewElement(group, "node");
            mxmlNewText(node, 0, "val6");

        node = mxmlNewElement(data, "node");
        mxmlNewText(node, 0, "val7");
        node = mxmlNewElement(data, "node");
        mxmlNewText(node, 0, "val8");

    FILE *pf = NULL;
    pf = fopen("/home/lius/workspace/lua_prj/test.xml","wb+");
    mxmlSaveFile (
        xml,
        pf,
        MXML_NO_CALLBACK
    );
    fclose(pf);
    return 0;
}

